import { defineStore } from "pinia";
import { ref } from "vue";
const usePageStore = defineStore(
  "page",
  () => {
    const page = ref<{
      pageSize: number;
      currentPage: number;
      search: string;
      total: number;
    }>({
      pageSize: 10,
      currentPage: 1,
      search: "",
      total: 100,
    });
    const setCurrentPage = (size: number) => {
      page.value.currentPage = size;
    };
    const setSearch = (search: string) => {
      page.value.search = search;
    };
    const setTotal = (total: number) => {
      page.value.total = total;
    };
    return {
      page,
      setCurrentPage,
      setSearch,
      setTotal,
    };
  },
  {
    persist: {
      storage: sessionStorage,
    },
  },
);
export { usePageStore };
